package fc.testmain;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import fc.FcHttpCon;
import jdk.internal.org.objectweb.asm.tree.MultiANewArrayInsnNode;

import java.util.Map;

public class T100DLXQ_CREATE {

    public static void main(String[] args) {
        String json_param=
                "{"+
                "\"key\": \"f5458f5c0f9022db743a7c0710145903\","+
                "\"type\": \"sync\","+
                "\"host\": {"+
                "\"prod\": \"oa\","+
                "\"ip\": \"192.168.0.1\","+
                "\"lang\": \"zh_CN\","+
                "\"acct\": \"tiptop\","+
                "\"timestamp\": \"20240729093204361\""+
                "},"+
                "\"service\": {"+
                "\"prod\": \"T100\","+
                "\"name\": \"apst300_crt\","+
                "\"ip\": \"192.168.0.2\","+
                "\"id\": \"topprd\""+
                "},"+
                "\"datakey\": {"+
                "\"EntId\": \"2\","+
                "\"CompanyId\": \"ZH00\""+
                "},"+
                "\"payload\": {"+
                "\"std_data\": {"+
                "\"parameter\": {"+
                "\"p1\": \"\","+
                "\"p2\": \"\""+
                "}"+
                "},"+
                "\"param\": {"+
                "\"top\": {"+
                "\"user_code\": \"ITADMIN\","+
                "\"memo\": \"备注，测试用\""+
                "},"+
                "\"data\": ["+
                "{"+
                "\"idx\": 1,"+
                "\"code\": \"121007002920\","+
                "\"requst_date\": \"2024-08-01\","+
                "\"amount\": 2,"+
                "\"project\": \"MWI-20240605004-1-2\","+
                "\"memo\": \"备注测试1\""+
                "},"+
                "{"+
                "\"idx\": 2,"+
                "\"code\": \"120407000233\","+
                "\"requst_date\": \"2024-08-02\","+
                "\"amount\": 3,"+
                "\"project\": \"MWI-20240605004-1-3\","+
                "\"memo\": \"备注测试2\""+
                "}"+
                "]"+
                "}"+
                "}"+
                "}";
        System.out.println(json_param);
        //调用 ECOLOGY 系统接口
        String data = HttpRequest.post(FcHttpCon.ZH_YFSY_XQ).body(json_param).execute().body();

        String result="ERROR";

        try {
            Object succesResponse = JSON.parse(data);
            Map map = (Map)succesResponse;
            Map map1 = (Map)map.get("payload");
            Map map2 = (Map)map1.get("std_data");
            Map map3 = (Map)map2.get("execution");
            if("0".equals(map3.get("code"))){
                result="SUCCESS";
            }
        } catch (Exception e) {}
System.out.println("RESULT:"+result);


/*        System.out.println("111："+map.get("payload"));
        System.out.println("222："+map1.get("std_data"));
        System.out.println("333："+map2.get("execution"));
        System.out.println("444："+map3.get("code"));*/

    }
}
